package com.miao.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class JSONResponse {

    private String code;
    private String msg;
    private Object data;

    public JSONResponse() {

    }

    public JSONResponse(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static JSONResponse ok() {
        return JSONResponse.ok(null);
    }

    public static JSONResponse ok(Object data) {
        return new JSONResponse("200", "success", data);
    }

    public static JSONResponse error() {
        return new JSONResponse("500", "fail", null);
    }


    public static JSONResponse error(String code, String msg) {
        return new JSONResponse(code, msg, null);
    }
}
